<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ASTS-客户工作台</title>
<script src="/customer_plat/public/javascripts/assets/js/jquery1.11.1.min.js"></script>
<script type="text/javascript" src="/customer_plat/public/javascripts/assets/chosen/amazeui.chosen.js"></script>
<script type="text/javascript" src="/customer_plat/public/javascripts/echarts-all.js?t=${System.currentTimeMillis()}"></script>

<link rel="stylesheet" href="/customer_plat/public/javascripts/assets/css/amazeui.min.css" />
 <link rel="stylesheet" href="/customer_plat/public/javascripts/assets/css/admin.css">
 <link rel="stylesheet" href="/customer_plat/public/javascripts/assets/chosen/amazeui.chosen.css" />
  <link rel="stylesheet" href="/customer_plat/public/select2/select2.min.css" />
 
 
<!--[if lt IE 9]>
<script src="/customer_plat/public/javascripts/assets/js/jquery1.11.1.min.js"></script>
<script src="/customer_plat/public/javascripts/assets/js/modernizr.js"></script>
<script src="/customer_plat/public/javascripts/assets/js/polyfill/rem.min.js"></script>
<script src="/customer_plat/public/javascripts/assets/js/polyfill/respond.min.js"></script>
<script src="/customer_plat/public/javascripts/assets/js/amazeui.legacy.js"></script>
<![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/customer_plat/public/javascripts/stringBuffer.js"></script>
<script src="/customer_plat/public/javascripts/assets/js/amazeui.min.js"></script>
<script type="text/javascript" src="/customer_plat/public/javascripts/assets/chosen/amazeui.chosen.js"></script>
<!--<![endif]-->
<script src="/customer_plat/public/javascripts/assets/js/app.js"></script>
 <script type="text/javascript" src="/customer_plat/public/select2/select2.min.js"></script>
<style>
.mt-15{
	margin-top: 15px;
}
</style>
 <!-- content start -->
<script>
var tableHTML = "";
function getCuttereByProjectId(cutter_id){
	 var params ={};
	 params.project_id = cutter_id;
	 $.post("/customer_plat/home.homeAction/getProjectCutter",params,function(data){
		 $("#material_id").html("");
		 var cutters = data.data;
			var str = "<option value='' >物料编码/工序/物料全称</option>";
			for(var i =0;i<cutters.length;i++){
				if(cutters[i].status=="0"){
				str+="<option value='"+cutters[i].material_id+"/"+cutters[i].process_id+"'>"+cutters[i].customer_specs_no+"/"+cutters[i].process_name+"/"+cutters[i].simple_specs_cust+"</option>";	
				}else{
					str+="<option value='"+cutters[i].material_id+"/"+cutters[i].process_id+"'>"+cutters[i].customer_specs_no+"/"+cutters[i].process_name+"/"+cutters[i].simple_specs_cust+"(已删)"+"</option>";	
				}
			}
			$("#material_id").html(str);
		 
	 });
	
}
function getOperatorProjectCutterDetails(operator_id){
	var params = {};
	params.operator_id=operator_id;
	$.post("getOperatorProjectCutterDetail",params,function(data){
		 var usecutters = data.data;
		 var table = "";
		 for(var i =0;i<usecutters.length;i++){
		 table  += "<tr>";
				table+= "<td>"+usecutters[i].project_name+"</td>";
				table+= "<td>"+usecutters[i].customer_specs_no+"</td>";
				table+= "<td>"+usecutters[i].long_specs_cust+"</td>";
				table+= "<td>"+usecutters[i].use_num+"</td>";
				table+= "<td>"+usecutters[i].rec_num+"</td>";
				table+= "<td>"+(usecutters[i].use_num-usecutters[i].rec_num)+"</td>";
			table+="</tr>"
			}
			$("#tbody").html(table);
			
	})
	
}
function addRecRecord(){
	$("#btn_add").attr("disabled","disabled");
	var params = {};
	var project_id = $("#project_id").val();
	var material_id = $("#material_id").val();
	var operator_id = $("#operator_id").val();
	var machine_id = $("#machine_id").val();
	var cutter_life = $("#cutter_life").val();
	var rec_desc = $("#rec_desc").val();
	var bag_type = $("#bag_type").val();
	var rec_status = $("#rec_status").val();
	if(operator_id==""){
	alert("请选择操作员！");
	$("#btn_add").removeAttr("disabled");
	return false;
	}
	if(project_id==""){
		alert("请选择项目！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}	
	if(material_id==""){
		alert("请选择刀具！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}
	if(machine_id==""){
		alert("请选择机台！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}
	if(rec_desc==""){
		alert("请选择回收原因！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}
	if(bag_type==""){
		alert("请选择刀具直径！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}
	if(rec_status==""){
		alert("请选择回收状态！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}
	if(cutter_life==""){
		alert("请填写寿命！");
		$("#btn_add").removeAttr("disabled");
		return false;
	}
	params.material_id = material_id;
	params.cutter_life = cutter_life;
	params.rec_desc = rec_desc;
	params.machine_id = machine_id;
	params.operator_id = operator_id;
	params.project_id = project_id;
	params.bag_type = bag_type;
	params.rec_status = rec_status;
	params.rec_desc = rec_desc;

	$.post("addRecRecordDo",params,function(data){
		alert("操作完成!");
		$("#btn_add").removeAttr("disabled");
		getOperatorProjectCutterDetails(operator_id);
		claerForm();
	})
}
function claerForm(){
	$("#operator_id option").eq(1).attr("selected",true);
	$("#machine_id option").eq(1).attr("selected",true);
	$("#project_id option").eq(1).attr("selected",true);
	$("#material_id option").eq(1).attr("selected",true);
	$("#rec_desc option").eq(1).attr("selected",true);
	$("#cutter_life").val("");	
}
$(function(){
	$("#project_id").select2();
	$("#machine_id").select2();
	$("#operator_id").select2();
	$("#material_id").select2();
	$("#rec_desc").select2();
	$("#project_id").change(function(){
		if($(this).val()!=""){
			 getCuttereByProjectId($(this).val());
		} 
	})
 	$("#operator_id").change(function(){
		if($(this).val()!=""){
			getOperatorProjectCutterDetails($(this).val());
		}
		
	})
})
</script>
<div class="admin-content">
	<div class="am-cf am-padding">
		<div class="am-fl am-cf">
			<strong class="am-text-primary am-text-lg">手动回收作业</strong> / <small>manualRecoveryRecord</small>
		</div>
	</div>
 
	<div class="am-g">
		<div class="am-u-sm-12" style="font-size:18px;float:left; border: 1px solid #999;border-radius:5px;margin:40px;width:96%;">
			<div style="width: 35%;margin-top: 20px;float: left;margin-bottom: 20px;">
		<div class="mt-15">
			操作员:&nbsp;&nbsp;&nbsp; <br>
			<select id="operator_id" name="operator_id"  style="width: 400px;" >
					<option value="">---选择操作员---</option>
						#{if operators!=null} 
						#{list items:operators?.data,as:'bean'}
						<option value="${bean?.operator_id}">${bean?.real_name}</option>
						#{/list} 
						#{/if}
				</select> 
			</div>
	
			<div class="mt-15">
			项目:&nbsp;&nbsp;&nbsp; <br>
			<select id="project_id" name="project_id"  style="width: 400px;" >
					<option value="">---选择项目---</option>
						#{if projects!=null} 
						#{list items:projects?.data,as:'bean'}
						<option value="${bean?.project_id}">${bean?.project_name}</option>
						#{/list} 
						#{/if}
				</select> 
			</div>
						<div class="mt-15">
			刀具:&nbsp;&nbsp;&nbsp;<br><select id="material_id" name="material_id" style="width: 400px;" class="form-control"  >
					<option value="">物料编码/工序/物料全称</option>
				</select>
				 </div>
					<div class="mt-15">
					机台 :&nbsp;&nbsp;&nbsp;<br><select id="machine_id"  style="width: 400px;" name="machine_id"   >
					<option value="">---选择机台---</option>
						#{if machines!=null} 
						#{list items:machines?.data,as:'bean'}
						<option value="${bean?.machine_id}">${bean?.machine_code}</option>
						#{/list} 
						#{/if}
				</select> 
				 </div>
				<div class="mt-15">
					回收原因:&nbsp;&nbsp;&nbsp;<br>
				<select id="rec_desc"  style="width: 400px;" name="rec_desc"   >
					<option value="">---选择回收原因---</option>
					<option value="新刀">新刀</option>
					<option value="断刀">断刀</option>
					<option value="崩刃">崩刃</option>
					<option value="横刀纹">横刀纹</option>
					<option value="竖刀纹">竖刀纹</option>
					<option value="起皱">起皱</option>
					<option value="侧面披锋">侧面披锋</option>
					<option value="正常磨损">正常磨损</option>
				</select> 
				 </div>
				 <div class="mt-15">
					刀具直径类型 :&nbsp;&nbsp;&nbsp;<br>
				<select id="bag_type"  style="width: 400px;" name="bag_type"   >
					<option value="">---选择刀具直径类型---</option>
					<option value="D2">D2</option>
					<option value="D4">D4</option>
					<option value="D6">D6</option>
					<option value="D8">D8</option>
					<option value="D10">D10</option>
					<option value="D12">D12</option>
				</select> 
				 </div>
				 
				 	 <div class="mt-15">
					回收类型 :&nbsp;&nbsp;&nbsp;<br>
				<select id="rec_status"  style="width: 400px;" name="rec_status"   >
					<option value="">---选择回收类型---</option>
					<option value="1">旧刀</option>
					<option value="2">新刀</option>
				</select> 
				 </div>
							<div class="mt-15">
			刀具寿命:<br><input type="text" id="cutter_life" maxlength="7" name="cutter_life" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"  style="border-radius:3px;">
										</div>
				<div class="mt-15">
				<button type="button" id="btn_add" onclick="addRecRecord()" class="am-btn am-btn-primary btn-loading-example"   >添加</button>
				</div>
			</div>
<div class="am-scrollable-horizontal" style="width: 1000px;height: 600px;overflow: scroll;margin-top: 50px;">
  <table class="am-table am-table-bordered am-table-striped am-text-nowrap">
				<thead>
					<tr>
						<th class="table-title">项目名称</th>
						<th class="table-title">物料编码</th>
						<th class="table-title">刀具规格</th>
						<th class="table-code">领用数量</th>
						<th class="table-code">归还数量</th>
						<th class="table-code">滞留数量</th>
					</tr>
				</thead>
				<tbody id="tbody" >
				</tbody>
				</table>
 </div>
			</div>
		</div>
	</div>
</div>
<!-- content end -->